package com.chinasofti.nio;

import java.nio.ByteBuffer;

public class CreayeByteBuffereDemo {
    public static void main(String[] args) {
        //method1();
        //method2();
        ByteBuffer byteBuffer2 = ByteBuffer.wrap("aaa".getBytes());
        for (int i = 0; i <3 ; i++) {
            //System.out.println(byteBuffer2.get());
        }
        System.out.println("byteBuffer2 = " + byteBuffer2);
    }

    private static void method2() {
        byte [] bytes = {97,98,99};
        ByteBuffer byteBuffer2 = ByteBuffer.wrap(bytes);
        for (int i = 0; i <3 ; i++) {
            //System.out.println(byteBuffer2.get());
        }
        System.out.println("byteBuffer2 = " + byteBuffer2);
    }

    private static void method1() {
        ByteBuffer byteBuffer = ByteBuffer.allocate(5);
        for (int i = 0; i <5 ; i++) {
            //System.out.println(byteBuffer.get());
        }
        System.out.println("byteBuffer = " + byteBuffer);
    }
}
